/**
 * create by young (young2f@outlook.com) on 2020/8/15
 */
'use strict';
const map = new Map();
const _utils = require('./utils');
map.set('deviceStatus', [
  {owner: 'deviceStatus', value: '运行中'},
  {owner: 'deviceStatus', value: '待机中'},
  {owner: 'deviceStatus', value: '故障中'},
  {owner: 'deviceStatus', value: '维护中'},
]);
map.set('manufacturer', [
  {owner: 'manufacturer', value: 'Modbus'},
  {owner: 'manufacturer', value: 'Simens'},
]);
const deviceDriveList = [
  {interfaceType: 'NET', manufacturer: 'Modbus', driveType: 'ModbusTCP'},
  {interfaceType: 'NET', manufacturer: 'Simens', driveType: 'S7'},
  {interfaceType: 'Serial', manufacturer: 'Modbus', driveType: 'ModbusRTU'},
  {interfaceType: 'Serial', manufacturer: 'Simens', driveType: 'PPI'},
  {interfaceType: 'Serial', manufacturer: 'omron', driveType: 'HT'},
];
export default {
  'POST /api/global/code/get': (req, res) => {
    console.log('mock', req.route.path, req.body);
    const {owner} = req.body;
    res.send({
      status: 'ok',
      result: {code: _utils.getUUID(8)}
    });
  },
  'POST /api/global/cities/get': (req, res) => {
    const file = require('./cities.json');
    res.send({
      status: 'ok',
      result: file
    });
  },


  'POST /api/base/data/query': (req, res) => {
    console.log('mock', req.route.path, req.body);
    const {owner} = req.body;
    res.send({
      status: 'ok',
      result: map.get(owner)
    });
  },
  'GET /api/base/device/drive/list': (req, res) => {
    console.log('mock', req.route.path, req.body);
    res.send({
      status: 'ok',
      result: deviceDriveList
    });
  }
};
